/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ci.core.dao.jpa;

import com.ci.core.dao.search.ExampleOptions;
import com.ci.core.dao.search.Filter;
import com.ci.core.dao.search.ISearch;
import com.ci.core.dao.search.SearchResult;
import java.io.Serializable;
import java.util.List;

/**
 * @author Lang Yu
 * @description
 * @date Aug 31, 2010 1:45:53 PM
 * @version 1.0
 */
public interface GenericDAO<T, ID extends Serializable> {
    // 获取实体本身

    public T find(ID id);

    public T[] find(ID... ids);
    // 获取引用

    public T getReference(ID id);

    public T[] getReference(ID... ids);
    // 添加更新以及批量添加更新操作

    public void persist(T... entities);

    public T merge(T entity);

    public T[] merge(T... entities);

    public T save(T entity);

    public T[] save(T... entities);
    // 删除的四种不同的方法，包括批量删除

    public boolean remove(T entity);

    public void remove(T... entities);

    public boolean removeById(ID id);

    public void removeByIds(ID... ids);
    // 查找所有的对应方法

    public List<T> findAll();
    // 搜索相关方法
    public <RT> List<RT> search(ISearch search);

    public <RT> RT searchUnique(ISearch search);

    public int count(ISearch search);

    public <RT> SearchResult<RT> searchAndCount(ISearch search);

    public Filter getFilterFromExample(T example);

    public Filter getFilterFromExample(T example, ExampleOptions options);

    // 三个特殊的方法
    public boolean isAttached(T entity);

    public void refresh(T... tntities);

    public void flush();
}
